package com.ds.infrastructure.hyperspace.monitor;

import com.ds.infrastructure.hyperspace.monitor.config.MetricsConfig;

import java.util.Set;
import java.util.concurrent.ExecutorService;

/**
 * @author  Weishaoying
 */
public interface MetricsManager {

    /**
     * Init metrics manager
     */
    void init(MetricsConfig metricsConfig, ExecutorService executorService) throws Exception;

    /**
     * Shutdown metrics manager and release resource
     */
    void shutdown();

    /**
     * Increment target connection gauge
     * @param serviceName
     * @param endpointType
     */
    void incrementConnectionGauge(String serviceName, EndpointType endpointType);

    /**
     * Decrement target connection gauge
     * @param serviceName
     * @param endpointType
     */
    void decrementConnectionGauge(String serviceName, EndpointType endpointType);

    /**
     * Increment exception counter
     * @param serviceName
     * @param endpointType
     */
    void incrementHyperspaceException(String serviceName, EndpointType endpointType);

    /**
     * Increment request pending gauge
     * @param serviceName
     */
    void incrementRequestPendingGauge(String serviceName);

    /**
     * Decrement request pending gauge
     * @param serviceName
     */
    void decrementRequestPendingGauge(String serviceName);

    /**
     * change target node status gauge
     * @param serviceName
     * @param nodeInfo
     * @param status
     */
    void changeTargetNodeStatusGauge(String serviceName, String nodeInfo, int status);

    /**
     * remove target node status
     * @param serviceName
     * @param retainTargetNodeSet
     */
    void removeTargetNodeStatusGauge(String serviceName, Set<String>retainTargetNodeSet);

    /**
     * Increment request counter
     * @param serviceName
     * @param gatewayStatus
     * @param targetStatus
     */
    void incrementRequestCounter(String serviceName, String gatewayStatus, String targetStatus);

    /**
     * Change request latency histogram
     * @param serviceName
     * @param gatewayLatency
     * @param targetLatency
     */
    void changeRequestLatencyHistogram(String serviceName, long gatewayLatency, long targetLatency);

    /**
     * Increment payload counter
     * @param serviceName
     * @param amount
     */
    void incrementPayloadCounter(String serviceName, int amount);

    /**
     * Increment entry request pending gauge
     * @param entryPort
     */
    void incrementEntryRequestPendingGauge(String entryPort);

    /**
     * Decrement entry request pending gauge
     * @param entryPort
     */
    void decrementEntryRequestPendingGauge(String entryPort);

    /**
     * Add the commit ID of GIT code to Prometheus, so that you can know the version of the currently running code
     * @param shortCommitId
     */
    void gitShortCommitIdGauge(String shortCommitId);

    /**
     * hyperspace current running container config version
     * @param version
     */
    void containerConfigVersionGauge(int version);

    /**
     * Opentracing total discarded  span.
     */
    void incrementTracerDiscardedSpanCounter();

    /**
     * Opentracing config
     * @param url
     * @param enable
     * @param sampleRate
     */
    void opentracingConfigGauge(String url, String enable,String sampleRate);
}
